<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<script src="ajax.js"></script>
</head>
<body>
用户：<input type="text" id="user"><br>
密码：<input type="password" id="password"><br>
<input type="button" value="注册" id="reg_btn">
<input type="button" value="登录" id="login_btn">

<script>
window.onload = function () {
    var oTxtUser = document.getElementById("user");
	var oTxtPass = document.getElementById("password");
	var oBtnReg =  document.getElementById("reg_btn");
	var oBtnLogin =  document.getElementById("login_btn");

	oBtnReg.onclick = function () {
		$.ajax({
		  url:'/user',
		  data:{
		    act:"reg",
		    user:oTxtUser.value,
		    pass:oTxtPass.value
		  },
		  type:'get',
		  success:function (str) {
		    var json = eval('('+str+')');
		    if(json.ok){
		    	alert('注册成功');
		    }else{
		    	alert('注册失败：'+json.msg);
		    }
		  },
		  error:function(){

		  }
		})
	}

	oBtnLogin.onclick = function () {
		$.ajax({

		})
	}

}
</script>
</body>
</html>